import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsOptional, IsBoolean, IsNumber, Min } from 'class-validator';

export class CreateCategoryDto {
  @ApiProperty({ description: '分类名称', example: '科技' })
  @IsNotEmpty({ message: '分类名称不能为空' })
  @IsString({ message: '分类名称必须是字符串' })
  name: string;

  @ApiProperty({ description: '分类描述', example: '包含各类科技相关书籍', required: false })
  @IsOptional()
  @IsString({ message: '分类描述必须是字符串' })
  description?: string;

  @ApiProperty({ description: '排序顺序', example: 1, required: false })
  @IsOptional()
  @IsNumber({}, { message: '排序顺序必须是数字' })
  @Min(0, { message: '排序顺序不能小于0' })
  sortOrder?: number;

  @ApiProperty({ description: '是否启用', example: true, required: false })
  @IsOptional()
  @IsBoolean({ message: '是否启用必须是布尔值' })
  isActive?: boolean;
}